#include<bits/stdc++.h>
using namespace std;

int n, num = 0, m1[10000][10], m2[10];

void peiliao(int total, int a)
{
	if(a == 10){
		if(total == n){
			for(int i = 0; i < 10; i++) m1[num][i] = m2[i];
			num++;
		}
	}
	else if(total >= n);
	else{
		for(int i = 1; i <= 3; i++){
			m2[a] = i;
			peiliao(total + i, a+1);
		}
	}
}

int main()
{
	cin >> n;
	peiliao(0, 0);
	cout << num << endl;
	for(int i = 0; i < num; i++){
		for(int j = 0; j < 10; j++){
			cout << m1[i][j] << " ";
		}
		cout << endl;
	}
	return 0;
}
